package com.ruizhong.integratedmediawithoutc.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruizhong.integratedmediawithoutc.dao.TSystemMapper;
import com.ruizhong.integratedmediawithoutc.entity.TSystem;
import com.ruizhong.integratedmediawithoutc.service.TSystemService;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class TSystemServiceImpl extends ServiceImpl<TSystemMapper, TSystem> implements TSystemService {
    @Override
    public TSystem getConfig() {
        return list().get(0);
    }

    @Override
    public void saveConfig(Map<String, Object> configMap) {
        lambdaUpdate().set(TSystem::getServerDir, configMap.get("server_dir").toString())
                .set(TSystem::getShareDir, configMap.get("share_dir").toString())
                .set(TSystem::getCodeType, configMap.get("code_type").toString())
                .set(TSystem::getCensor, (Boolean) configMap.get("censor"))
                .eq(TSystem::getId, 1)
                .update();
    }
}
